<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>进制转换</title>
    <script>
      /*
       *   0b:二进制
       *   0o:八进制
       *   0x:十六进制
       *   toString(X)  X进制的转换
       */
      console.log(0b10); //2
      console.log(0o10); //8
      console.log(0x10); //16

      console.log(0b11 === 3); //true
      console.log(0o10 === 8); //true
      console.log(0x10 === 16); //true

      let num = 10;
      console.log(num.toString(8)); //12
      console.log(num.toString(2)); //1010
      console.log(num.toString(16)); //a
      console.log(num.toString(5)); //20

      console.log(parseInt("1010", 2)); // 二进制转10进制  10
      console.log(parseInt("12", 8)); // 八进制转10进制   10
      console.log(parseInt("a", 16)); // 16进制转10进制    10
      console.log(parseInt("20", 5)); // 5进制转10进制    10
    </script>
  </head>
  <body></body>
</html>
